from PyQt5.Qt import *

from UI.ui_Menu import *
from audio import Voice


class Menu(QWidget, Ui_menu):
    def __init__(self, parent=None):
        super(Menu, self).__init__(parent)
        self.setupUi(self)
        self.select_index = 12
        self.label_group = [self.label, self.label_2, self.label_3,
                            self.label_4, self.label_5, self.label_6,
                            self.label_7, self.label_8, self.label_9,
                            self.label_10, self.label_11, self.label_12,
                            self.label_13, self.label_14, self.label_15]

        self.set_label_color()
        self.voice = None
        self.last_label = self.label_13

    def set_index(self, i):
        if i == 1:
            self.last_label = self.label_group[self.select_index]
           # print(self.select_index)
            self.select_index -= 1
            if self.select_index == -1:
                self.select_index = 14
            self.voice = Voice('左移')
            self.voice.start()

        elif i == 2:
            self.last_label = self.label_group[self.select_index]
           # print(self.select_index)
            self.select_index += 1
            if self.select_index == 15:
                self.select_index = 0
            self.voice = Voice('右移')
            self.voice.start()

        self.set_label_color()

    def set_label_color(self):
        for item in self.label_group:
            item.setStyleSheet('QLabel{'
                               'font: 12pt bold "楷体";'
                               'font-weight:900;'
                               'text-align:center center;'
                               'color:white;'
                               'border:5px solid;'
                               'border-radius:10px;'
                               'border-color: #cac3b8;'
                               'background-color: grey;/*定义最小高度和最小宽度*/'
                               'min-height: 60px;'
                               'min-width: 60px;}')

        self.label_group[self.select_index].setStyleSheet('QLabel{'
                                                          'font: 12pt bold "楷体";'
                                                          'font-weight:900;'
                                                          'text-align:center center;'
                                                          'color:white;'
                                                          'border:5px solid;'
                                                          'border-radius:10px;'
                                                          'border-color: #cac3b8;'
                                                          'background-color: #f34c19;/*定义最小高度和最小宽度*/'
                                                          'min-height: 60px;'
                                                          'min-width: 60px;}'
                                                          )
